package gengine.common.packets;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

/**
 * User: Arseniy
 * Date: 21.12.11
 * Time: 9:21
 */
public class MessagePacket extends BasePacket{
    private String message;
    private int targetId;

    public MessagePacket(String message,int targetId) {
        this.message = message;
        this.targetId=targetId;
    }

    public MessagePacket(){};


    @Override
    public PacketTypeEnum getPacketType() {
        return PacketTypeEnum.Message;
    }


    @Override
    protected void readCore(ObjectInputStream stream) throws IOException {
        message = stream.readUTF();
        targetId = stream.readInt();
    }

    @Override
    protected void writeCore(ObjectOutputStream stream) throws IOException {
        stream.writeUTF(message);
        stream.writeInt(targetId);
    }

    public String getMessage() {
        return message;
    }

    public int getTargetId() {
        return targetId;
    }
}
